<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Delete Group</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<h3>Select the Group to Delete</h3>
<form action="#" method="post">
Select Group:<br/>
<select name="name">
<option value="N/A">Select a Group from Dropdown</option>
<?php 
$conn=mysql_connect("localhost","root","") or die("Could not Establish Connection".mysql_error());
$db=mysql_select_db("contacts_ms",$conn) or die("No DB Selected".mysql_error());
$st="EM";
$qry=mysql_query("SELECT * FROM info_group");
while($r=mysql_fetch_array($qry)){
	if($r['status']==$st){ ?>
		<option value="<?php echo $r['name'] ?>"> <?php echo $r['name'] ?></option> <?php
	}
}
?>
</select><br/><br/>
<input type="submit" value="Delete Group" name="submit" class="sbtns">&emsp;&emsp;&emsp;
<input type="reset" name="reset" value="Cancel" class="sbtns">
</form>
<?php
if(isset($_POST['submit'])){
	$name=$_POST['name'];
	$myqry=mysql_query("DELETE FROM info_group WHERE name='$name'");
	if(!$myqry) $res="Could Not Delete Group, try again later!".mysql_error();
	else $res="Group Deleted Successfully!";
	echo $res;
}
?>
</body>
</html>